﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Project.Database.Repository
{
    public partial class DatabaseRepository
    {
        private List<SelectListItem> adtypelist = new List<SelectListItem>();
        public IEnumerable<SelectListItem> GetAdTypes()
        {
            if (adtypelist.Count == 0)
            {
                foreach (AdType adtype in entities.AdTypes)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text = adtype.Name;
                    item.Value = adtype.ID.ToString();
                    adtypelist.Add(item);
                }
            }
            return adtypelist;
        }

        private List<SelectListItem> countrylist = new List<SelectListItem>();
        public IEnumerable<SelectListItem> GetCountries()
        {
            if (countrylist.Count == 0)
            {
                foreach (Country country in entities.Countries)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text = country.Name;
                    item.Value = country.ID.ToString();
                    countrylist.Add(item);
                }
            }
            return countrylist;
        }

        private List<SelectListItem> catlist = new List<SelectListItem>();
        public IEnumerable<SelectListItem> GetCategories()
        {
            if (catlist.Count == 0)
            {
                foreach (BlogCategory bcat in entities.BlogCategories)
                {
                    var item = new SelectListItem();
                    item.Text = bcat.Name;
                    item.Value = bcat.CategoryID.ToString();
                    catlist.Add(item);
                }
            }
            return catlist;
        }
    }
}